var http = require("http");
var fs = require('fs');
var path = require("path");

http.createServer((req,res) => {
    res.writeHead(200,{'Content-type': 'text/html'});

    var filePath = path.join(__dirname,"../123abc.jpg");
    var imgBuf = fs.readFileSync(filePath);//读取文件内容
    var imgBase64 = imgBuf.toString('base64');

    res.write(
        "<!DOCTYPE html> <html>" + 
        "<head></head><body>" + 
        "<img src = 'data:image/jpg; base64," + 
        imgBase64 + "' />" + "</body></html>"
    )

    res.end();
}).listen(8081);